package com.oamicnet.servicetwo.server.service.impl;

import com.oamicnet.servicetwo.server.entity.Course;
import com.oamicnet.servicetwo.server.mapper.CourseMapper;
import com.oamicnet.servicetwo.server.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public List<Course> findAll() {
        return courseMapper.selectList(null);
    }

    @Override
    public void save(Course course) {
        courseMapper.insert(course);
    }

    @Override
    public void update(Course course) {
        courseMapper.updateById(course);
    }

    @Override
    public Course get(Long id) {
        return courseMapper.selectById(id);
    }

    @Override
    public void delete(Long id) {
        courseMapper.deleteById(id);
    }
}
